<?php


namespace app\controller\archives;
require_once __DIR__.'/../../common/AuthController.php';
use app\common\AuthController;


/**
 * 行业
 */
class Trade extends AuthController
{   


    /**
     * 初始化操作
     */
    public function init()
    {

    }
	

    /**
     * 获取行业列表
     */
	public function api_archives_trade_getList($msg)
    {   
        global $db;
        $page = isset($msg['data']['page'])?$msg['data']['page']:1;
        $rows = isset($msg['data']['rows'])?$msg['data']['rows']:15;
        $info = [
           'id' => isset($msg['data']['id'])?$msg['data']['id']:'',
           'name' => isset($msg['data']['name'])?$msg['data']['name']:'',
           'type' => isset($msg['data']['type'])?$msg['data']['type']:'',
        ];
        $limit = ($page-1)*$rows.','.$rows;
        $where = 'status = 1';
        if(!empty($info['id'])){
            $where .= " AND id =".$info['id'];
        }
        if(!empty($info['name'])){
            $where .= " AND name LIKE '%".$info['name']."%'";
        }
        if($info['type']){
            $field = "`id`,`name`";
        }else{
            $field = "*";
        }
        $res = $db->query("SELECT $field from trade WHERE ".$where." limit ".$limit);
        $count =  $db->query("SELECT count(*) as count from trade WHERE ".$where);
		return $this->outMessage(10000,'获取成功',$res,'success',$count[0]['count']);
	}




 

}
